import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 编码信息信息 */
export interface CodeList {
  id: number // id
  code?: string // 扫码信息
  partNumber: string // 零件编号
  supplyCode: string // 供应商代码
  partUniqueCode: string // 零件唯一码
  batchInfo: string // 批次信息
  factoryInfo: string // 工厂
}

// 编码信息 API
export const CodeListApi = {
  // 查询编码信息分页
  getCodeListPage: async (params: any) => {
    return await request.get({ url: `/business/code-list/page`, params })
  },

  // 查询编码信息详情
  getCodeList: async (id: number) => {
    return await request.get({ url: `/business/code-list/get?id=` + id })
  },

  // 新增编码信息
  createCodeList: async (data: CodeList) => {
    return await request.post({ url: `/business/code-list/create`, data })
  },

  // 新增编码信息 失败的
  createFailCode: async (data: CodeList) => {
    return await request.post({ url: `/business/code-list/createFail`, data })
  },

  checkData: async (data) => {
    return await request.put({ url: `/business/code-list/check`, data })
  },

  // 修改编码信息
  updateCodeList: async (data: CodeList) => {
    return await request.put({ url: `/business/code-list/update`, data })
  },

  // 删除编码信息
  deleteCodeList: async (id: number) => {
    return await request.delete({ url: `/business/code-list/delete?id=` + id })
  },

  /** 批量删除编码信息 */
  deleteCodeListList: async (ids: number[]) => {
    return await request.delete({ url: `/business/code-list/delete-list?ids=${ids.join(',')}` })
  },

  // 导出编码信息 Excel
  exportCodeList: async (params) => {
    return await request.download({ url: `/business/code-list/export-excel`, params })
  }
}
